<template>
    <el-dialog :title="detailData.plateNo" :visible.sync="outerVisible" width="1000px">

        <div class="flex flex-direction ">
            <div v-loading="detailLoading" class="flex">
                <div class="flex-sub margin-right flex flex-direction">
                    <span style="float: right;">车牌号：</span>
                    <el-input  v-model="detailData.plateNo" placeholder="请输入车牌号"/>
                    <span style="float: right;">车辆品牌：</span>
                    <el-input  v-model="detailData.vehicleBrand" placeholder="请输入车辆品牌"/>
                    <span style="float: right;">车辆子品牌：</span>
                    <el-input  v-model="detailData.subBrand" placeholder="请输入车辆子品牌"/>
<!--                    <template slot-scope="scope">-->
                        <el-button type="text" size="" icon="el-icon-document-checked" @click="submit()">修改</el-button>
<!--                    </template>-->
<!--                    <div style="width: 150px; z-index: 999; text-align: right; position: absolute; right: 20px; top: 65px;">-->
<!--                        <el-button size="mini" type="primary" icon="el-icon-arrow-left"-->
<!--                                   @click="getParentDetails(indexs -1)">-->
<!--                            上一条-->
<!--                        </el-button>-->
<!--                        <el-button size="mini" type="primary"-->
<!--                                   @click="getParentDetails(indexs +1)">-->
<!--                            下一条<i class="el-icon-arrow-right el-icon&#45;&#45;right" />-->
<!--                        </el-button>-->
<!--                    </div>-->
<!--                    <vehicle-info :detail-data="detailData" />-->
                    <div class="flex  margin-top-sm" style="margin-top: 10px;">
                        <!--                        <el-button v-show="step !='qt'" size="mini" type="primary" icon="el-icon-edit" style="width: 120px;" @click="handleEdit">编辑驾驶员信息</el-button>-->
                    </div>
                </div>
                <!--                <vehicle-media :table-data="tableData" style="width: 50%;" />-->
                <vehicle-media :detail-data="detailData" style="width: 80%;" />
            </div>

        </div>
    </el-dialog>
</template>

<script>
    // import {UpdateBasicInformation, InsertBasicInformation} from '@/api/overrunPenaltyApi';
    // import {GetVehicleDetectDetail} from '@/api/parkUnloadApi';
    import moment from 'moment';
    import VehicleInfo from '@/modules/components/VehicleDetail/vehicle-info';
    import VehicleMedia from '@/modules/components/VehicleDetail/vehicle-media';
    import  {UpdateEntrance} from '@/api/parkUnloadApi';
    export default {
        name: 'EntrancePic',
        components: {
            VehicleInfo, VehicleMedia
        },
        model: {
            prop: 'value',
            event: 'change'
        },
        props: {
            information: Object,
            initDetailData: Object,
            initDetailData1: Object,
            // deviceType: Object,
            // 当前返回list的条数
            tableSize: Number,
            // 当前选中列在数据中的下标值
            indexs: Number,
            // 当前页
            currentPage: Number,
            // 当前查询的数据的总条数(分页的总数)
            total: Number,
            isAdd: {
                type: Boolean,
                default: false
            },
            step: String
        },
        data() {
            return {
                // 处罚对象单位信息和处罚对象个人信息单选
                radio: '',
                totalCount: 0,
                unitInfoUnable: false,
                personInfoUnable: false,
                outerVisible: false,
                detailLoading: false,
                isDisabled: false,
                invalidReasonFlag: false,
                isLoading : false,
                isIllegal: '',
                tableData: [],
                localVehicleDetail: null,
                queryParams: {},
                // detailData:{},
            };
        },
        computed: {
            detailData() {
                return this.localVehicleDetail || this.initDetailData;;
            },
            // detailData1(){
            //     return this.initDetailData1;
            // }
        },
        watch: {
            initDetailData(val) {
                // this.localVehicleDetail = null;
                // this.queryParams = {
                //     Parameter: '1',
                //     CurrentPage: 1,
                //     plate_no: val.plate_no
                // };
                // this.mediaTab = 'img';
                this.initForm();
            }
            // information(newValue, oldValue) {
            //     this.form = newValue;
            //     // this.radio = '';
            //     this.unitInfoUnable = false;
            //     this.personInfoUnable = false;
            //     this.queryParams = {
            //         CurrentPage: 1
            //     };
            // }
            // detailData(newValue, oldValue){
            //     this.initForm();
            // }
        },
        mounted() {
            this.initForm();
        },
        methods: {
            moment,
            initForm() {
                // this.form = this.information;
                // this.isLoading = true;
                // GetVehicleDetectDetail(this.detailData1).then(res => {
                //     this.tableData = res.res.GetVehicleDetectDetail;
                //     console.log("数组");
                //     console.log(this.tableData);
                // }).catch(err => {
                //     this.isLoading = false;
                //     console.log(err);
                // });

            },
            submit(){
                debugger
                let date = {
                    entranceId : this.detailData.entranceId,
                    plateNo :this.detailData.plateNo,
                    vehicleBrand: this.detailData.vehicleBrand,
                    subBrand: this.detailData.subBrand,
                    entranceId: this.detailData.entranceId
                };
                UpdateEntrance(date).then(res => {
                    if (res.res.UpdateEntrance == 'Success' || res.res.process_id == this.currentProcessId) {
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                        this.closeDialog();
                        this.getList();
                    } else {
                        this.$message({
                            message: res.res.CloseTheCase,
                            type: 'warning'
                        });
                    }
                }).catch(err => {
                    console.log(err);
                });
            },
            handleTabClick() {
                this.queryParams.CurrentPage = 1;
                this.initForm();
            },
            // handleView(i){
            handleView(item){
                this.detailLoading = true;

                setTimeout(() => {
                    this.localVehicleDetail = item;
                    this.detailLoading = false;
                }, 100);
                initForm();
                console.log(this.tableData);
                console.log("查看detailData1");
                console.log(this.localVehicleDetail);
            },
            show() {
                this.outerVisible = true;
            },
            showHandleResult(param) {
                if (param.target.tagName == 'SPAN') {
                    this.invalidReasonFlag = true;
                }

            },
            // getParentDetails(index) {
            //     console.log(index);
            //     if (index < 0) {
            //         if (this.currentPage == 1) {
            //             this.$message({
            //                 message: '已是第一条',
            //                 type: 'warning'
            //             });
            //             return false;
            //         } else {
            //             this.$emit('getList', this.currentPage - 1);
            //             index = 0;
            //             setTimeout(() => {
            //                 this.$emit('handleView', index);
            //             }, 1000);
            //         }
            //     }
            //     if (this.tableSize == index) {
            //
            //         if (((this.currentPage - 1) * 20 + index + 1) > this.total) {
            //             this.$message({
            //                 message: '已是最后一条',
            //                 type: 'warning'
            //             });
            //             return false;
            //         } else {
            //             this.$emit('getList', this.currentPage + 1);
            //             index = 0;
            //             setTimeout(() => {
            //                 this.$emit('handleView', index);
            //             }, 1000);
            //             return false;
            //         }
            //     }
            //     this.$emit('handleView', index);
            // },

            // isBlank(str) {
            //     return !this.isNotBlank(str);
            // },
            // isNotBlank(str) {
            //     if (str != null && str != undefined && str != '' & str != ' ') {
            //         return true;
            //     }
            //     return false;
            // }
        }
    };
</script>

<style scoped>
    >>>.el-button--mini,
    >>>.el-button--mini.is-round {
        padding: 7px 5px;
    }
    >>>.el-tabs__header {
        padding: 0;
        position: relative;
        margin: 0;
    }
    /deep/
    .el-dialog__body {
        padding: 10px 20px;
    }
    /deep/
    .el-dialog__header {
        padding: 20px 20px 10px;
        border-bottom: 1px solid #dcdfe6;
    }

</style>

